package com.fourhats.controller;

import java.io.IOException;
import java.util.Locale;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.support.RequestContextUtils;

@Controller
public class CommonController {

	@RequestMapping(value = "/common/changeLanguage")
	public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		try {
			RequestContextUtils.getLocaleResolver(request).setLocale(request,
					response, new Locale(request.getParameter("siteLanguage")));
		} catch (Exception ex) {
		}

		response.sendRedirect(request.getContextPath() + "/");
	}

	@RequestMapping(value = "/contact")
	public String index() {
		return "content/contact";
	}

	@RequestMapping(value = "/howTo")
	public String howTo() {
		return "content/howTo";
	}
}